from tw.api import WidgetsList,CSSLink,js_callback
from tw.forms import ListForm,TableForm
from tw.forms.fields import HiddenField
from tg import url
from tw.jquery.autocomplete import AutoCompleteField

records_autocomplete = AutoCompleteField(
                   id='records_autocomplete',
                   completionURL = 'fetch_records',
                   fetchJSON = True,
                   minChars = 3)

parties_autocomplete = AutoCompleteField(
                   id='parties_autocomplete',
                   completionURL = '/party/fetch_parties',
                   fetchJSON = True,
                   minChars = 2)

party_parent_autocomplete = AutoCompleteField(# this is such a stupid hack
                   id='parties_autocomplete',
                   label_text=u'',
                   completionURL = '/party/fetch_parties',
                   fetchJSON = True,
                   minChars = 2)


from tw.forms import TableForm

records_autocomplete_form = TableForm(id='records_autocomplete_form', children=[records_autocomplete])
parties_single_autocomplete_form = ListForm(template="lifepyscle.widgets.templates.inline_list_form"\
    ,id='parties_autocomplete_form', children=[parties_autocomplete])

party_parent_form = TableForm(template="lifepyscle.widgets.templates.inline_list_form",\
            submit_text=u"Update",id='party_parent_form', children=[party_parent_autocomplete])
